home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.peer.DialogPeer;
-
- public class Dialog extends Window {
- boolean resizable;
- boolean modal;
- String title;
- private static final String base = "dialog";
- private static int nameCounter;
- private static final long serialVersionUID = 5920926903803293709L;
-
- public Dialog(Frame parent) {
- this(parent, "", false);
- }
-
- public Dialog(Frame parent, String title) {
- this(parent, title, false);
- }
-
- public Dialog(Frame parent, String title, boolean modal) {
- super(parent);
- this.resizable = true;
- if (parent == null) {
- throw new IllegalArgumentException("null parent frame");
- } else {
- super.name = "dialog" + nameCounter++;
- this.title = title;
- this.modal = modal;
- }
- }
-
- public Dialog(Frame parent, boolean modal) {
- this(parent, "", modal);
- }
-
- public void addNotify() {
- if (super.peer == null) {
- super.peer = ((Window)this).getToolkit().createDialog(this);
- }
-
- super.addNotify();
- }
-
- public String getTitle() {
- return this.title;
- }
-
- public boolean isModal() {
- return this.modal;
- }
-
- public boolean isResizable() {
- return this.resizable;
- }
-
- protected String paramString() {
- String str = super.paramString() + (this.modal ? ",modal" : ",modeless");
- if (this.title != null) {
- str = str + ",title=" + this.title;
- }
-
- return str;
- }
-
- public void setModal(boolean b) {
- this.modal = b;
- }
-
- public synchronized void setResizable(boolean resizable) {
- this.resizable = resizable;
- DialogPeer peer = (DialogPeer)super.peer;
- if (peer != null) {
- peer.setResizable(resizable);
- }
-
- }
-
- public synchronized void setTitle(String title) {
- this.title = title;
- DialogPeer peer = (DialogPeer)super.peer;
- if (peer != null) {
- peer.setTitle(title);
- }
-
- }
-
- public void show() {
- synchronized(((Component)this).getTreeLock()){}
-
- try {
- if (super.parent != null && super.parent.getPeer() == null) {
- super.parent.addNotify();
- }
-
- if (super.peer == null) {
- this.addNotify();
- }
- } catch (Throwable var3) {
- throw var3;
- }
-
- ((Container)this).validate();
- if (super.visible) {
- ((Window)this).toFront();
- } else {
- super.visible = true;
- if (this.isModal()) {
- EventDispatchThread dt = null;
- if (Thread.currentThread() instanceof EventDispatchThread) {
- dt = new EventDispatchThread("AWT-Dispatch-Proxy", Toolkit.getEventQueue());
- ((Thread)dt).start();
- }
-
- if ((super.state & 1) == 0) {
- ((Window)this).postWindowEvent(200);
- super.state |= 1;
- }
-
- super.peer.show();
- if (dt != null) {
- dt.stopDispatching();
- }
- } else {
- super.peer.show();
- if ((super.state & 1) == 0) {
- ((Window)this).postWindowEvent(200);
- super.state |= 1;
- }
- }
- }
-
- }
- }
-